<template>
	<view class="container" >
		
		
		
		<navbar @transfer="checkHotelHandle" :isShowPre="true" :navTitle="hotelName"></navbar>
		
		<view v-if="showall">
			<view class="content">
				<view class="content-item">
					<view class="content-top">
						{{indexData.estimatedRevenue||0}}
						<text>预计营收</text>
					</view>
					<view class="conten-center">
						<view class="center-item">
							{{indexData.expectedOccupancyRate?Number(indexData.expectedOccupancyRate*100).toFixed(0):0}}%
							<text>预计入住率</text>
						</view>
						<view class="center-item">
							{{indexData.revPAR?Number(indexData.revPAR):0}}
							<text>RevPAR</text>
						</view>
						<view class="center-item">
							{{indexData.saleRoom||0}}
							<text>可售房</text>
						</view>
						<view class="center-item">
							{{indexData.occupancyRate?Number(indexData.occupancyRate*100).toFixed(0):0}}%
							<text>实时入住率</text>
						</view>
					</view>
				</view>
				
				<view class="list">
					<view class="item" @tap="gotoRevenue">
						<image src="../../static/icon5.png" mode=""></image>
						<text>营收报表</text>
					</view>
					<view class="item" @tap="gotoForward">
						<image src="../../static/icon6.png" mode=""></image>
						<text>远期房态</text>
					</view>
					<view class="item" @tap="gotoGroup">
						<image src="../../static/icon7.png" mode=""></image>
						<text>集团数据</text>
					</view>
					<view class="item" @tap="showNoneHanlde">
						<image src="../../static/icon8.png" mode=""></image>
						<text>渠道分析</text>
					</view>
				</view>
				
				<view class="centent-bottom">
					<view class="centent-title">
						<view class="title-btn">
							
						</view>
						<text>各房型出租情况（已售/剩余）</text></view>
					<!-- <view class="bottom-item" style="margin-top: 20rpx;" v-for="(item,index) in indexData.roomTypeCountStatisticsList" :key="index">
						{{item.roomTypeName}} <text>{{item.occupancyRate?Number(item.occupancyRate*100).toFixed(0):0}}%</text>
					</view> -->
					<view class="room-list">
						<view class="room-item" v-for="(item,index) in indexData.roomTypeCountStatisticsList" :key="index">
							<view class="room-top">
								<image :src="getImageSrc(index)" mode=""></image>
								<text class="room-name">{{item.roomTypeName}}</text>
							</view>
							<view class="room-bottom">
								{{item.soldCount}}/{{item.leftCount}}
							</view>
						</view>
					</view>
					
				</view>
				
					<u-modal :show-title="true" :show-cancel-button="true" @confirm="gotoHotelList()" v-model="hotelShow" :content="content"></u-modal>
				
			</view>
		</view>
		<view class="imgconent"  v-else >
			<image style="width: 750rpx;" src="https://image.maxiaokeji.com/A01A54/nodata2.png" mode="aspectFit"></image>
			<text>暂无查看权限，请使用房态功能</text>
		</view>
		
	</view>
	
	
	
</template>

<script>
	import navbar from '@/components/navBar.vue'
	
	import {statistics} from '@/api/index.js'
	export default {
		components:{
			navbar
		},
		data() {
			return {
				indexData:{
					roomTypeCountStatisticsList:[]
				},
				hotelName:'',
				content:"是否切换酒店?",
				hotelShow:false,
				showall:false
			}
		},
		onLoad() {
			// wx.getSystemInfo({
			// 	success: res => {
			// 		const statusBarHeight = res.statusBarHeight
			// 		const navigationHeight = statusBarHeight + 44 + 'px';
			// 	}
			// })

		},
		onShow() {
			this.hotelName=uni.getStorageSync('name')+ ' ' +'v'
			uni.setNavigationBarTitle({
				title:this.hotelName
			})
			this.statisticsHandle()
		},
		methods: {
			gotoGroup(){
				uni.navigateTo({
					url:'/pages/index/groupData'
				})
			},
			getImageSrc(index) {
			     const icons = ['icon1', 'icon2', 'icon3', 'icon4'];
			     const iconName = icons[index % icons.length];
			     return `../../static/${iconName}.png`;
			   },
			showNoneHanlde(){
				uni.showToast({
					title:'即将上线',
					icon:"none"
				})
			},
			checkHotelHandle(){
				
				// this.hotelShow=true
				uni.navigateTo({
					url:'/pages/hotelsList/hotelsList'
				})
			},
			async statisticsHandle(){
				const res =await statistics()
				this.indexData=res.data
				if(this.indexData==null){
					console.log("11")
					this.showall=false
				}else{
					this.showall=true
				}
			},
			gotoForward(){
				uni.navigateTo({
					url:'/pages/house/forwardHouse'
				})
			},
			gotoRevenue(){
				uni.navigateTo({
					url:'/pages/index/revenue'
				})
			},
			gotoHotelList(){
				this.hotelShow=false
				uni.navigateTo({
					url:'/pages/hotelsList/hotelsList'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		background-color: #f7f7f7;
		min-height: 100vh;
	}
	.imgconent{
		width: 100%;
		background-color: #FFFFFF;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 20rpx 0;
		text{
			font-size: 14px;
			color: #000;
			margin-top: 20rpx;
		}
	}
	.top{
		height: 120rpx;
		background: #FFFFFF;
		padding: 0 20rpx;
		display: flex;
		align-items: center;
		font-family: Source Han Sans SC;
		font-weight: 500;
		font-size: 40rpx;
		color: #000;
		font-weight: bold;
		
	}
	.check-btn{
		margin-left: 20rpx;
		width: 164rpx;
		height: 80rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 6rpx 12rpx rgba(93,95,238,0.12);
		border-radius: 20rpx;
		text-align: center;
		line-height: 80rpx;
		color: #1296db;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
	}
	.content{
		padding:  20rpx;
		
		box-sizing: border-box;
	}
	.content-top{
		font-family: Alibaba PuHuiTi 2.0;
		font-size: 48rpx;
		font-weight: 500;
		font-variation-settings: "opsz" auto;
		/* Black */
		color: #000000;
		display: flex;
		flex-direction: column;
		text{
			font-family: Alibaba PuHuiTi 2.0;
			font-size: 32rpx;
			font-weight: 300;
			color: #000;
			letter-spacing: 0.32px;
		}
	}
	.content-item{
		background-color: #FFFFFF;
		padding: 44rpx 30rpx;
		box-sizing: border-box;
		border-radius: 10rpx;
	}
	.conten-center{
		margin-top: 56rpx;
		display: flex;
		align-items: center;
		
		.center-item{
			width: 25%;
			font-family: Source Han Sans SC;
			
			font-size: 36rpx;
			color: #000;
			display: flex;
			flex-direction: column;
			font-family: Alibaba PuHuiTi 2.0;
			
			font-weight: 500;
			line-height: 22px;
			color: #000;
			// align-items: center;
			text{
				
			
				color: #000;
				font-family: Alibaba PuHuiTi 2.0;
				font-size: 24rpx;
				font-weight: 300;
			}
		}
	}
	.centent-bottom{
		width: 702rpx;
		// height: 368rpx;
		background: #FFFFFF;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		margin-top: 32rpx;
		padding: 24rpx 0;
		.centent-title{
			display: flex;
			align-items: center;
			
			.title-btn{
				width: 8rpx;
				height: 32rpx;
				background: #0868FA;
			}
			
			text{
				font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
				font-weight: 700;
				font-size: 34rpx;
				color: #3D3D3D;
				margin-left: 12rpx;
			}
		}
		.room-list{
			padding: 0 24rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			
			.room-item{
				margin-top: 20rpx;
				width: 318rpx;
				height: 116rpx;
				background: #F6F5F8;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				padding-top: 20rpx;
				padding-left: 32rpx;
				box-sizing: border-box;
				.room-top{
					display: flex;
					align-items: center;
					image{
						width: 24rpx;
						height: 24rpx;
					}
					.room-name{
						margin-left: 12rpx;
						font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #8A8A8A;
					}
				}
				
				.room-bottom{
					margin-left: 36rpx;
					margin-top: 8rpx;
					font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
					font-weight: 700;
					font-size: 34rpx;
					color: #3D3D3D;
				}
			}
		}
		.bottom-item{
			display: flex;
			align-items: center;
			
			text{
				margin-left: 20rpx;
			}
		}
	}
	
	.list{
		margin-top: 20rpx;
		display: flex;
		// flex-wrap: wrap;
		justify-content: space-around;
		align-items: center;
		background-color: #FFFFFF;
		border-radius: 8rpx;
		height: 170rpx;
		box-sizing: border-box;
		.item{
			display: flex;
			flex-direction: column;
			align-items: center;
			image{
				width: 88rpx;
				height: 88rpx;
				
			}
			text{
				// margin-top: 10rpx;
				
				font-family: Source Han Sans, Source Han Sans;
				font-weight: 400;
				font-size: 24rpx;
				color: #020202;
			}
			
		}
		// .item:nth-child(n+2){
		// 	margin-left: 20rpx;
		// }
	}
</style>
